package com.wymobilearchitecture.heade_frist.adapter;

import com.wymobilearchitecture.heade_frist.adapter.duck.MallardDuck;
import com.wymobilearchitecture.heade_frist.adapter.duck.RedheadDuck;
import com.wymobilearchitecture.heade_frist.adapter.duck.RubberDuck;

public class Test {

    public static void main(String[] args) {


        //想要实现叫的行为
        //针对实现编程
        Dag dag = new Dag();
        dag.wangwangSpeak();

        //针对接口编程
        Animal animal = new Dag();
        animal.mackSound();


        //针对实现编程
        Duck duck = new RubberDuck();
        duck.display();
        duck.fly();
        duck.quack();

        ////针对接口编程--策略模式
        Duck mallard = new MallardDuck();
        mallard.display();
        mallard.performFly();
        mallard.performQuack();

        Duck redDuck = new RedheadDuck();
        redDuck.display();
        redDuck.performFly();
        redDuck.performQuack();

        Duck rubberDuck = new RubberDuck();
        rubberDuck.display();
        rubberDuck.performFly();
        rubberDuck.performQuack();
    }



    static abstract class Animal{
        //针对接口编程
        protected abstract void mackSound();
    }

    static class Dag extends Animal{
        //针对接口编程
        @Override
        protected void mackSound() {
            wangwangSpeak();
        }

        //针对实现编程
        private void wangwangSpeak(){
            System.out.println("wangwangSpeak");
        }
    }

    static class Cat extends Animal{
        //针对接口编程
        @Override
        protected void mackSound() {
            miaomiaoSpeak();
        }

        //针对实现编程
        private void miaomiaoSpeak(){
            System.out.println("wangwangSpeak");
        }
    }
}
